package com.dingding.dubbo.framework;

import com.dingding.dubbo.framework.protocol.http.HttpProtocolImpl;
import com.dingding.dubbo.framework.protocol.netty.NettyProtocolImpl;
import org.apache.commons.lang3.StringUtils;

/**
 * @program: spring-learning
 * @description:
 * @author: liugongding
 * @create: 2022-02-16 17:11
 **/
public class ProtocolFactory {

    public static Protocol getProtocol(){
        String name = System.getProperty("protocolName");
        if (StringUtils.isBlank(name)) {
            return new HttpProtocolImpl();
        }
        switch (name) {
            case "http":
                return new HttpProtocolImpl();
            case "netty":
                return new NettyProtocolImpl();
            default:
                break;
        }
        return new HttpProtocolImpl();
    }
}


